/*
 * NodeDisplay.java
 *
 * Created on 07 August 2003, 09:15
 * Copyright (C) 2003, Velocityme Partnership
 */

package com.velocityme.client.gui;

import com.velocityme.client.gui.contactdetail.ContactDetailTypeControl;
import com.velocityme.client.gui.directory.DirectoryControl;
import com.velocityme.client.gui.exception.ExceptionWindow;
import com.velocityme.client.gui.node.contactable.department.DepartmentControl;
import com.velocityme.client.gui.node.contactable.organisation.OrganisationControl;
import com.velocityme.client.gui.node.contactable.person.PersonControl;
import com.velocityme.client.gui.node.group.GroupControl;
import com.velocityme.client.gui.node.NodeControl;
import com.velocityme.client.gui.node.role.RoleControl;
import com.velocityme.client.gui.node.state.StateControl;
import com.velocityme.client.gui.node.status.StatusControl;
import com.velocityme.client.gui.node.task.action.ActionControl;
import com.velocityme.client.gui.node.task.anchor.AnchorControl;
import com.velocityme.client.gui.node.task.issue.IssueControl;
import com.velocityme.client.gui.node.task.project.ProjectControl;
import com.velocityme.client.gui.node.taskstatemachine.TaskStateMachineControl;
import com.velocityme.client.gui.node.user.UserControl;
import com.velocityme.interfaces.*;
import com.velocityme.client.gui.exception.*;
import com.velocityme.client.gui.licencemanagement.LicenceManagementControl;
import com.velocityme.client.gui.loginhistory.LoginHistoryControl;
import com.velocityme.client.gui.node.systemnode.SystemNodeControl;
import com.velocityme.client.gui.systemproperty.SystemPropertyControl;
import com.velocityme.valueobjects.NodeValue;
import java.rmi.RemoteException;
import java.util.Set;
import javax.ejb.FinderException;
import javax.naming.NamingException;

/**
 *
 * @author  Robert Crida Work
 */
public class NodeDisplay {
    
    static public java.awt.Component getDisplay(KeySession p_key, NodeValue p_nodeValue, Set p_setPermissions) {
        String type = p_nodeValue.getType();
        if (type.equals("Contactable")) {
            String contactableType = p_nodeValue.getFinalType();
            if (contactableType.equals("Organisation"))
                return new OrganisationControl(p_key, new OrganisationPK(p_nodeValue.getNodeId()), false, p_setPermissions);
            if (contactableType.equals("Department"))
                return new DepartmentControl(p_key, new DepartmentPK(p_nodeValue.getNodeId()), false, p_setPermissions);
            if (contactableType.equals("Person"))
                return new PersonControl(p_key, new PersonPK(p_nodeValue.getNodeId()), false, p_setPermissions);
        }
        if (type.equals("User"))
            return new UserControl(p_key, new UserPK(p_nodeValue.getNodeId()), false, p_setPermissions);
        if (type.equals("Group"))
            return new GroupControl(p_key, new GroupPK(p_nodeValue.getNodeId()), false, p_setPermissions);
        if (type.equals("Role"))
            return new RoleControl(p_key, new RolePK(p_nodeValue.getNodeId()), false, p_setPermissions);
        if (type.equals("TaskStateMachine"))
            return new TaskStateMachineControl(p_key, new TaskStateMachinePK(p_nodeValue.getNodeId()), false, p_setPermissions);
        if (type.equals("State"))
            return new StateControl(p_key, new StatePK(p_nodeValue.getNodeId()), false, p_setPermissions);
        if (type.equals("Status"))
            return new StatusControl(p_key, new StatusPK(p_nodeValue.getNodeId()), false, p_setPermissions);
        if (type.equals("Task")) {
            String taskType = p_nodeValue.getFinalType();
            if (taskType.equals("Project"))
                return new ProjectControl(p_key, new ProjectPK(p_nodeValue.getNodeId()), false, p_setPermissions);
            if (taskType.equals("Anchor"))
                return new AnchorControl(p_key, new AnchorPK(p_nodeValue.getNodeId()), false, p_setPermissions);
            if (taskType.equals("Action"))
                return new ActionControl(p_key, new ActionPK(p_nodeValue.getNodeId()), false, p_setPermissions);
            if (taskType.equals("Issue"))
                return new IssueControl(p_key, new IssuePK(p_nodeValue.getNodeId()), false, p_setPermissions);
        }
        if (type.equals("Node")) {
            String nodeType = p_nodeValue.getFinalType();
            if (nodeType.equals("ContactDetailTypes"))
                return new ContactDetailTypeControl(p_key, p_setPermissions);
            if (nodeType.equals("SystemProperties"))
                return new SystemPropertyControl(p_key, p_setPermissions);
            if (nodeType.equals("LicenceManagement"))
                return new LicenceManagementControl(p_key, p_setPermissions);
            if (nodeType.equals("LoginHistory"))
                return new LoginHistoryControl(p_key, p_setPermissions);
            if (nodeType.equals("Directory"))
                return new DirectoryControl(p_key, p_setPermissions);
            if (nodeType.equals("SystemNode"))
                return new SystemNodeControl(p_key, p_nodeValue.getPrimaryKey());
        }
        return new NodeControl(p_key, p_nodeValue.getPrimaryKey(), false, p_setPermissions);
    }
}
